DOUBLE PRECISION FUNCTION contoh(x)
	IMPLICIT NONE
	double precision x
	contoh = 1/(1+x)
END

DOUBLE PRECISION function soal1(x)
	IMPLICIT NONE
	double precision x
	soal1 = exp(-x) / (1+sqrt(x)+x**2)
	!soal1 = 1/(1+x)
END

DOUBLE PRECISION function soal2(x,y)
	IMPLICIT NONE
	double precision x,y
	soal2 = (x**3)*y
END

DOUBLE PRECISION function soal2_xtetap(y)
	IMPLICIT NONE
	double precision x_tetap,y
	common /xtetap/ x_tetap
	soal2_xtetap = (x_tetap**3)*y
END

DOUBLE PRECISION function soal3(x)
	IMPLICIT NONE
	double precision x
	soal3 = x
END

DOUBLE PRECISION function soal5_rekayasa(t)
! constant T = 1
	IMPLICIT NONE
	double precision t, constant_T, pi, temp
	pi = 3.1415926535897932384626433832795
	constant_T = 1.0
	if ((t.ge.0).and.(t.le.(constant_T/2))) then
		temp = 10 * exp(t/constant_T) * sin(2*pi*t/constant_T)
		soal5_rekayasa = temp ** 2
	else if ((t.ge.(constant_T/2)).and.(t.le.constant_T)) then
		soal5_rekayasa = 0
	end if
END


DOUBLE PRECISION function contoh_dif(x,y)
	IMPLICIT NONE
	double precision x, y
	contoh_dif = x + y
END

DOUBLE PRECISION function soal1_dif(x,y)
	IMPLICIT NONE
	double precision x, y
	soal1_dif = x**3 + y**2
END


DOUBLE PRECISION function soal_2_dif_dy(x,y,z)
	IMPLICIT NONE
	double precision x,y,z
	
	soal_2_dif_dy = -0.5 * y
END

DOUBLE PRECISION function soal_2_dif_dz(x,y,z)
	IMPLICIT NONE
	double precision x,y,z
	
	soal_2_dif_dz = 4 -0.3 * z - 0.1 * y
END


DOUBLE PRECISION function soal2Rdy(x,y,z)
	IMPLICIT NONE
	double precision x,y,z
	
	soal2Rdy = z
	!soal2Rdy = -0.5*y
	
END

DOUBLE PRECISION function soal2Rdz(x,y,z)
	IMPLICIT NONE
	double precision x,y,z
	
	! cek nilai x mendekati 0, z_soal2_rekayasa_dif mendekati 0 juga
	if (x.eq.0) then
		soal2Rdz = -1*((0.1*(y**2))**1.5)/3
	else
		soal2Rdz = (-2*z/x)-((0.1*y**2)**1.5)
	end if
	!soal2Rdz = 4-0.3*z-0.1*y
	
END

DOUBLE PRECISION function soal3Rdy(x,y,z)
	IMPLICIT NONE
	double precision x,y,z
	soal3Rdy = z
end

DOUBLE PRECISION function soal3Rdz(x,y,z)
	IMPLICIT NONE
	double precision x,y,z,R,L,C
	R = 4.7
	L = 0.05
	C = 0.001
	soal3Rdz = -1*((R*z)+(y/C))/L
end

